class HomeListEntity {
  HomeListData data;
  int code;
  String msg;

  HomeListEntity({this.data, this.code, this.msg});

  HomeListEntity.fromJson(Map<String, dynamic> json) {
    data =
        json['data'] != null ? new HomeListData.fromJson(json['data']) : null;
    code = json['code'];
    msg = json['msg'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.data != null) {
      data['data']['list'] = this.data.toJson();
    }
    data['code'] = this.code;
    data['msg'] = this.msg;
    return data;
  }
}

class HomeListData {
  List<HomeListDataData> datas;

  HomeListData();

  HomeListData.fromJson(Map<String, dynamic> json) {
    if (json['list'] != null) {
      datas = new List<HomeListDataData>();
      (json['list'] as List).forEach((v) {
        datas.add(new HomeListDataData.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.datas != null) {
      data['list'] = this.datas.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class HomeListDataData {
//	article_id	文章ID
//cat_id	文章分类ID
//title	文章标题
//author	作者
//keywords	关键词
//description	简要说明
//pubtime	发布时间
//img	标题图片
//bigimg	大图片
//file	文件
//clicknum	浏览量
  String href;
  String article_id;
  String title;
  String author;
  String keywords;
  String pubtime;
  String img;
  String clicknum;
  String description;
  String imglist;
  List<String> imglists;
//	String article_id;
//	int publishtime;
//	int visible;
//	String nicedate;
//	String projectlink;
//	String author;
//	String prefix;
//	int zan;
//	String origin;
//	String chaptername;
//	String link;
//	String title;
//	int type;
//	int userid;
//	List<HomeListDataDatasTag> tags;
//	String apklink;
//	String envelopepic;
//	int chapterid;
//	int superchapterid;
//	int id;
//	bool fresh;
//	bool collect;
//	int courseid;
//	String desc;
  HomeListDataData(
      {this.article_id,
      this.description,
      this.title,
      this.author,
      this.imglist,
      this.keywords,
      this.href,
      this.pubtime,
      this.img,
      this.clicknum});

  HomeListDataData.fromJson(Map<String, dynamic> json) {
    article_id = json['article_id'].toString();
    title = json['title'];
    author = json['author'];
    keywords = json['keywords'];
    href = json['href'];
    pubtime = json['pubtime'];
    img = json['img'];
    imglist = json['imglist'].toString();
    print(imglist);
    if (imglist.length > 5) {
      imglists = imglist.replaceAll('[', '').replaceAll(']', '').replaceAll(" ", "").split(",");
    } else {
      imglists = new List();
      imglists.add(img);
    }
    // (imglist as List).forEach((v) {
    //   imglists.add(v);
    // });
    // if (imglists.length == 0 && img != "" && img != null) {
    //   imglists.add(img);
    // }
    clicknum = json['clicknum'].toString();
    description = json['description'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['article_id'] = this.article_id;
    data['title'] = this.title;
    data['author'] = this.author;
    data['keywords'] = this.keywords;
    data['pubtime'] = this.pubtime;
    data['img'] = this.img;
    data['href'] = this.href;
    data['imglist'] = this.imglist;
    data['clicknum'] = this.clicknum;
    data['description'] = this.description;
    return data;
  }
}

class HomeListDataDatasTag {
  String name;
  String url;

  HomeListDataDatasTag({this.name, this.url});

  HomeListDataDatasTag.fromJson(Map<String, dynamic> json) {
    name = json['name'];
    url = json['url'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['name'] = this.name;
    data['url'] = this.url;
    return data;
  }
}
